// 本地存储模拟数据源，提供视图所需的读取函数

const NEWS_KEY = 'newsData'
const STAFF_KEY = 'staffData'
const GALLERY_KEY = 'galleryData'
const DONOR_KEY = 'donorData'

function readFromLocalStorage(key, fallback) {
  try {
    const raw = localStorage.getItem(key)
    if (!raw) return fallback
    const parsed = JSON.parse(raw)
    return Array.isArray(parsed) ? parsed : fallback
  } catch {
    return fallback
  }
}

export function getNewsData() {
  return readFromLocalStorage(NEWS_KEY, [])
}

export function getStaffData() {
  return readFromLocalStorage(STAFF_KEY, [])
}

export function getGalleryData() {
  return readFromLocalStorage(GALLERY_KEY, [])
}

export function getDonorData() {
  return readFromLocalStorage(DONOR_KEY, [])
}


